{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7e8bd8b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle f{\\left(x \\right)} = \\left(C_{1} + C_{2} x\\right) e^{x} + \\frac{\\cos{\\left(x \\right)}}{2}$"
      ],
      "text/plain": [
       "Eq(f(x), (C1 + C2*x)*exp(x) + cos(x)/2)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sympy import *\n",
    "f = symbols('f', cls=Function)\n",
    "x ,k= symbols('x k')\n",
    "eq = Eq(f(x).diff(x, x) - 2*f(x).diff(x) + f(x), sin(x))\n",
    "dsolve(eq, f(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9d2dbf8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle f{\\left(x \\right)} = C_{1} e^{- k x} + C_{2} e^{k x}$"
      ],
      "text/plain": [
       "Eq(f(x), C1*exp(-k*x) + C2*exp(k*x))"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq = Eq(f(x).diff(x,x) -k*k* f(x), 0)\n",
    "dsolve(eq, f(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "49555f9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "f=sin(x)+cos(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f7a988ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - (\\sin{\\left(x \\right)} + \\cos{\\left(x \\right)})$"
      ],
      "text/plain": [
       "-(sin(x) + cos(x))"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f.diff(x,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e56418d0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
